home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!sschaem
- From: sschaem@teleport.com (Stephan Schaem)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: 7 Jan 1996 14:43:43 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4com6v$415@maureen.teleport.com>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <4b77tq$htp@serpens.rhein.de> <MQAQx*XOe@yaps.rhein.de> <4bqhnf$6g5@sunsystem5.informatik.tu-muenchen.de> <jasonb.820051107@cs.uwa.edu.au> <4c9i2l$h3i@sunsystem5.informatik.tu-muenchen.de> <4cf0ep$233@ra.i
- <4ck47h$g07@maureen.teleport.com> <jasonb.820919731@cs.uwa.edu.au>
- NNTP-Posting-Host: julie.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Jason S Birch (jasonb@cs.uwa.edu.au) wrote:
- : sschaem@teleport.com (Stephan Schaem) writes:
- : >Lars Duening (duening@ibr.cs.tu-bs.de) wrote:
- : >: If a have to access hardware registers (never had to so far), I will
- : >: not do this by direct pointers, but instead define a structure
- : >: representing them. This is then the only place where I have to worry
- : >: about .c, .w and .l, everywhere else I can write
- : >: 'chipregs->blt0con = *b++;' and let the compiler figure the rest out.
- : >: HLLs win again here: the compiler will warn if *b is of the wrong
- : >: type, and if I defined the structure wrong (your .w/.l example), I
- : >: just have to correct the structure, not the n statements where it is
- : >: used. And the compiler would even take care of bitshifts where
- : >: necessary.
-
- : > You let the compiler tell you AFTER you write your code about the type?
-
- : That's not what he said. He said the only place he has to worry about .c, .w
- : and .l is where he's defining his structures (although even then, it would be
- : extremely rare) and after that he can just use his new types, relying on the
- : compiler to give a warning if he's made a mistake.
-
-
- I dont think he can declare like this: chipregs.bltcon0 con0;
- So he will need so 'worry' about it when he declare con0, he will
- read ushort when peeking the structure (Like the asm coder) or
- maybe he typedefed ushort chipreg; and will use this instead.
- *b could be a pointer to float for all he cares, dont you think its
- wise to know what data your are manipulating so you can declare your
- variable correctly?!?!
-
- : > Beleive me, you need to know before you write that line what type
- : > is chipmems->blt0con...
-
- : He needs to know how he's defined it, yes - but not whether it turns into a .c,
- : .w, or .l. It could be written as a UCHAR, a LONG, or even typedef'd to a
- : BILBY. Read it again.
-
- He needs to know how he declared it too... meaning he has to know when
- he write the code what is the type on bltcon0.. a uword or a BILBY (typdef
- for uword)... And if he as a few brain cell left he will remember that
- when he use the variable. EX when I declare float, long in a function
- I know wich is wich otherwise I might store a float temp result
- in a long and bang!
-
- : [...]
-
- : > Yea, I agree... move.w (ax)+,(a1)+ just mean : "Copy 2 bytes from a0 to
- : > a1, and increment both address by 2"
- : > In C the equivalent to move.? (a0)+,(a1)+ is
- : > A++ = B++;
- : > And that beying defined somewhere:
- : > ushort *A,*B;
-
- : That's only the C equivalent on certain platforms. C itself says nothing about
- : the actual size of its various types, other than a relative ordering.
-
- ANSI define very well the minimum size of its type.
-
- : > Same thing to me... Aside that in ASM you dont get type checking at
- : > compile time.
-
- : Well, two big differences are that the type name need have nothing to
- : do with the number of bits used to encode it, and that you only need to
- : specify it *once*, when you declare the variable. (If you have multiple
- : declarations, you can use typedef to create the type at the beginning
- : and still only have it specified in one place.) If you later discover
- : you've got it wrong, you can change the type of the variable in its
- : declaration (or the typedef). Sure beats going through a large assembly
- : program trying to work out exactly which .l's should have been .w...
-
- Yes, thats very true... in asm you only have fixed type. But typedef is
- not really a part of the compiler but preprocessor, and could be easely
- integrated to an assembler.(But its not, so its hell when you modify
- structure)
-
- #typedef .w .chipreg
-
- move.chipreg (GLOBAL_x1,a4),(CHIPREG_bltcon0,a1)
-
-
-
- : > Do you really write code where you dont know what you are writting?
-
- : Again, that's not what he said.
-
-
- Stephan
-